/*
 * Copyright (C) 2010 by Lei Shi (sjtushi@gmail.com)
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License, 
 * version 2, or any later versions.
 * --------------------
 * This program is build on XenAccess library which is created Brayan Payne. 
 *     http://code.google.com/p/xenaccess/
 *
 * This program could be used in Xen domain0 to list all opened files 
 * information of specfic process <pid> in paravirtualization guest 
 * domainU <domid>. 
 *
 * Usage: xen-lsof <domid> <pid>
 *
 * Like lsof command used in domainU linux.
 *
 */
#ifndef _XEN_LSOF_H_
#define _XEN_LSOF_H_

#include "proc.h"
#include "stack.h"

#define MAX_FILENAME_LENGTH 100

typedef enum {
   READONLY = 0,
   WRITEONLY = 1,
   READWRITE = 2,
} file_flag_t;

struct proc_file_info;

struct proc_file_info{
   uint32_t fd;
   char filename[MAX_FILENAME_LENGTH];
   file_flag_t flag;
   struct proc_file_info *next;
};

typedef struct proc_file_info proc_file_info_t;

proc_file_info_t* get_files_info(xa_instance_t*, addr_t);

void print_file_info(proc_file_info_t *);

void free_list(proc_file_info_t*);

char* get_dentry_name(xa_instance_t*, addr_t);

char* get_filemnt(xa_instance_t*, addr_t);


#endif // _XEN_LSOF_H_
